#pragma once
#include<iostream>
#include<string>
#include<time.h>

std::string Gettime()
{
    //获取时间戳
    time_t t = time(nullptr);
    //
    struct tm *curr = ::localtime(&t);//localtime将时间戳转换为时间

    char currtime[32];
    //转换成字符串,写到currtime里
    snprintf(currtime,sizeof(currtime),"%d-%d-%d %d:%d:%d",
    curr->tm_year + 1900,
    curr->tm_mon + 1,
    curr->tm_mday,
    curr->tm_hour,
    curr->tm_min,
    curr->tm_sec);

    return currtime;
}
